#include<bits/stdc++.h>
using namespace std;
int p[100050],n,m,L,V;
struct car{
    int d,v,a,l,r;
}s[100050];
inline int read()
{
    char c=getchar();
    while((c<'0'||c>'9')&&c!='-')
    c=getchar();
    int ret=0,f=1;
    if(c=='-')
    {
        c=getchar();
        f=-1;
    }
    while(c=='-'||(c>='0'&&c<='9'))
    {
        ret=(ret<<1)+(ret<<3)+c-48;
        c=getchar();
    }
    return ret*f;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    srand(time(NULL));
    while(T--)
    {
        n=read(),m=read(),L=read(),V=read();
        for(int i=1;i<=n;i++)
        s[i].d=read(),s[i].v=read(),s[i].a=read();
        for(int i=1;i<=m;i++)
        p[i]=read();
        int ans1=0;
        for(int i=1;i<=n;i++)
        {
            if(s[i].a==0)
            {
                if(s[i].v>V&&s[i].d<=p[m])
                {
                    ans1++;
                    s[i].l=upper_bound(p+1,p+m+1,s[i].d-1)-p;
                    s[i].r=m;
                }
            }
            else if(s[i].a>0)
            {
                double S=(V*V-s[i].v*s[i].v)/2.0/s[i].a;
                int x=max(s[i].d,s[i].d+(int)ceil(S));
                int y=upper_bound(p+1,p+m+1,x)-p;
                if(y<=m)
                {
                    ans1++;
                    s[i].l=y;
                    s[i].r=m;
                }
            }
            else if(s[i].a<0)
            {
                double S=(s[i].v*s[i].v-V*V)/2.0/(-s[i].a);
                int x=max(s[i].d,s[i].d+(int)ceil(S));
                int y=upper_bound(p+1,p+m+1,x-1)-p-1;
                if(y>=1&&y<=m&&p[y]>=s[i].d)
                {
                    ans1++;
                    s[i].l=upper_bound(p+1,p+m+1,s[i].d-1)-p;
                    s[i].r=y;
                }
            }
        }
        printf("%d %d\n",ans1,rand()%ans1);
    }
    return 0;
}
